package com.tmc.platform.common;

import java.util.HashMap;
import java.util.Map;

import com.tmc.constant.FareConstant.Platform;
import com.tmc.platform.ctrip.CtripOrderServiceImpl;
import com.tmc.platform.ctrip.CtripPolicyServiceImpl;
import com.tmc.util.ObjectUtil;

public class ServiceCenter {

	public static Map<String, OrderService> orderServiceMap = null;
	
	public static Map<String, PolicyService> policyServiceMap = null;

	public static OrderService getOrderService(String platformCode) {
		if (ObjectUtil.noText(platformCode)) {
			platformCode = Platform.ctrip.getCode();
		}
		if (orderServiceMap == null) {
			orderServiceMap = new HashMap<String, OrderService>();
			initOrderMap();
		}
		return orderServiceMap.get(platformCode);
	}

	private static void putIntoMap(OrderService service) {
		orderServiceMap.put(service.getPlatForm().getCode(), service);
	}

	private static void initOrderMap() {
		//putIntoMap(new CtripOrderServiceImpl());
	}
	
	public static PolicyService getPolicyService(String platformCode) {
		if (ObjectUtil.noText(platformCode)) {
			platformCode = Platform.ctrip.getCode();
		}
		if (policyServiceMap == null) {
			policyServiceMap = new HashMap<String, PolicyService>();
			initPolicyMap();
		}
		return policyServiceMap.get(platformCode);
	}

	private static void putIntoMap(PolicyService service) {
		policyServiceMap.put(service.getPlatForm().getCode(), service);
	}

	private static void initPolicyMap() {
		putIntoMap(new CtripPolicyServiceImpl());
	}
}
